<html>
<head><meta charset="utf-8"><title>Generic Closure Wrapping without new type? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html">Generic Closure Wrapping without new type?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247103234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247103234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247103234">(Jul 25 2021 at 02:00)</a>:</h4>
<p>Given a function that takes a callback <code>F: Fn(X) -&gt; Y</code>, is there a pattern through which I can share common behaviour for that type and still statically dispatch through generics?</p>
<p>I'm looking to cull boilerplate out of a vaguely-monadic API, but I'm having a hard time making it strongly-typed.<br>
The following presents the general shape of the problem, but I can't find a solution that doesn't involve <code>impl</code> despite knowing the exact function that <code>impl</code>s it.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">type</span> <span class="nc">Input</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="k">type</span> <span class="nc">Output</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="k">fn</span> <span class="nf">do_the_thing</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">input</span>: <span class="nc">Self</span>::<span class="n">Input</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Output</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">FooDoer</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">f</span>: <span class="nc">F</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="n">i</span>: <span class="nc">PhantomData</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="n">r</span>: <span class="nc">PhantomData</span><span class="o">&lt;</span><span class="n">R</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">FooDoer</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">  </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="n">I</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">R</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">type</span> <span class="nc">Input</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">I</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="k">type</span> <span class="nc">Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">R</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="k">fn</span> <span class="nf">do_the_thing</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">input</span>: <span class="nc">Self</span>::<span class="n">Input</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Output</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">f</span><span class="p">)(</span><span class="n">input</span><span class="p">)</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">make_foo</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="p">(</span><span class="n">f</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">FooDoer</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"> </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="n">I</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">R</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">FooDoer</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">f</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">i</span>: <span class="nc">PhantomData</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">r</span>: <span class="nc">PhantomData</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="c1">// This `impl` feels like the root of thee problem; I can't close</span>
<span class="c1">// over `f` without passing a value, but also cannot provide a generic,</span>
<span class="c1">// non-impl type for anything that creates a closure.</span>
<span class="k">fn</span> <span class="nf">make_some_wrapper</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="p">,</span><span class="o">&gt;</span><span class="p">(</span><span class="n">f</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="nb">Fn</span><span class="p">(</span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;</span><span class="n">R</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"> </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="n">I</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">R</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">move</span><span class="w"> </span><span class="o">|</span><span class="n">i</span><span class="o">|</span><span class="w"> </span><span class="n">i</span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">x</span><span class="o">|</span><span class="w"> </span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">))</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="c1">// Succeeds but makes it impossible to generically handle from a monadic context</span>
<span class="c1">// I already know the exact implementor and want to represent that in the type signature</span>
<span class="k">fn</span> <span class="nf">make_foo_substantiated_impl</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="p">(</span><span class="n">f</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">FooDoer</span><span class="o">&lt;</span><span class="k">impl</span><span class="w"> </span><span class="nb">Fn</span><span class="p">(</span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;</span><span class="n">R</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">R</span><span class="o">&gt;&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">  </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="n">I</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">R</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">FooDoer</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">f</span>: <span class="nc">make_some_wrapper</span><span class="p">(</span><span class="n">f</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">i</span>: <span class="nc">PhantomData</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">r</span>: <span class="nc">PhantomData</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="c1">// Errors with: `Expected type, found function`</span>
<span class="c1">// It looks like a `typeof` would fit here, or that even a turbofish should resolve it...</span>
<span class="k">fn</span> <span class="nf">make_foo_substantiated</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="p">(</span><span class="n">f</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">FooDoer</span><span class="o">&lt;</span><span class="n">make_some_wrapper</span><span class="o">&lt;</span><span class="n">F</span><span class="p">,</span><span class="w"> </span><span class="n">I</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">R</span><span class="o">&gt;&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"> </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="n">I</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">R</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">FooDoer</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">f</span>: <span class="nc">make_some_wrapper</span><span class="p">(</span><span class="n">f</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">i</span>: <span class="nc">PhantomData</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">r</span>: <span class="nc">PhantomData</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Trying to use the <code>impl</code> solution fails in my case because I'm using a trait to implement the behaviour over a monadic type, a context in which the compiler produces an <a href="https://doc.rust-lang.org/error-index.html#E0562">E0562</a> due to impl usage in a non-"inherent method" return-type.</p>
<p>I suspect a general solution to this typing problem may also help us add <code>async fn</code> to traits, as well as enable a whole host of higher-order functional programming techniques or at least reduce the boilerplate and complexity involved in writing them.</p>



<a name="247104501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247104501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247104501">(Jul 25 2021 at 02:41)</a>:</h4>
<blockquote>
<p>Given a function that takes a callback F: Fn(X) -&gt; Y, is there a pattern through which I can share common behaviour for that type and still statically dispatch through generics?</p>
</blockquote>
<blockquote>
<p>The following presents the general shape of the problem, but I can't find a solution that doesn't involve impl despite knowing the exact function that impls it.</p>
</blockquote>
<p>I think you're a little confused - <code>impl Fn</code> means "a (single) unnamed type which implements Fn". It's not dynamically dispatched, that would be <code>Box&lt;dyn Fn&gt;</code>.</p>



<a name="247104503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247104503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247104503">(Jul 25 2021 at 02:41)</a>:</h4>
<p>you can't remove it in this case because closure types can't be named in rust, you can only say <code>impl Fn</code></p>



<a name="247104610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247104610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247104610">(Jul 25 2021 at 02:45)</a>:</h4>
<p>changing the signature of <code>make_foo_substantiated</code> to <code>fn make_foo_substantiated&lt;F, I, R&gt;(f: F) -&gt; FooDoer&lt;impl Fn(Option&lt;I&gt;) -&gt; Option&lt;R&gt;, Option&lt;I&gt;, Option&lt;R&gt;&gt;</code> works fine: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=f36bea89cc0622b994eebbb32ddcbe6b">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=f36bea89cc0622b994eebbb32ddcbe6b</a></p>



<a name="247104613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247104613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247104613">(Jul 25 2021 at 02:45)</a>:</h4>
<p>(I'm a little confused why you have PhantomData when you also have a function with those inputs and outputs, but it doesn't affect the example much)</p>



<a name="247105271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247105271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247105271">(Jul 25 2021 at 03:06)</a>:</h4>
<blockquote>
<p>I think you're a little confused - impl Fn means "a (single) unnamed type which implements Fn". It's not dynamically dispatched, that would be Box&lt;dyn Fn&gt;.</p>
</blockquote>
<p>I know that <code>impl</code> isn't dynamically dispatched- the point of my  question was that I was trying to avoid resorting to dynamic dispatch when a solution should be soluble through generics.</p>
<blockquote>
<p>(I'm a little confused why you have PhantomData when you also have a function with those inputs and outputs, but it doesn't affect the example much)</p>
</blockquote>
<p>It wouldn't compile without them; it said <code>I</code> or <code>R</code> were unconstrained despite actually using the <code>F: Fn(I) -&gt; R</code> constraint on them. Maybe that's a compiler bug?</p>
<blockquote>
<p>changing the signature of make_foo_substantiated to fn make_foo_substantiated&lt;F, I, R&gt;(f: F) -&gt; FooDoer&lt;impl Fn(Option&lt;I&gt;) -&gt; Option&lt;R&gt;, Option&lt;I&gt;, Option&lt;R&gt;&gt; works fine</p>
</blockquote>
<p>Yes, if you read the definition of <code>make_foo_substantiated_impl</code>, you just rewrote the same thing. I explained in my commentary why this is not viable in a trait context due to <a href="https://doc.rust-lang.org/error-index.html#E0562">E0562</a>.</p>
<blockquote>
<p>you can't remove it in this case because closure types can't be named in rust, you can only say impl Fn</p>
</blockquote>
<p>Indeed, allowing naming of closure types with generic parameters for the closed-over context would actually solve this problem. As would allowing <code>impl</code>-returns in a trait context.</p>
<p>That's the problem.</p>



<a name="247105723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247105723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247105723">(Jul 25 2021 at 03:21)</a>:</h4>
<p>can you explain what you mean by a trait context?</p>



<a name="247105725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247105725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247105725">(Jul 25 2021 at 03:21)</a>:</h4>
<p>I think you might be looking for <code>#![feature(type_alias_impl_trait)]</code></p>



<a name="247106064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247106064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247106064">(Jul 25 2021 at 03:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F/near/247105723">said</a>:</p>
<blockquote>
<p>can you explain what you mean by a trait context?</p>
</blockquote>
<p>Given the above <code>impl</code>-returning form, try it such that <code>make_foo_substantiated_impl</code> is a method inside a trait, and you will hit <a href="https://doc.rust-lang.org/error-index.html#E0562">E0562</a>.</p>
<p>Traits cannot have a method which returns a type containing <code>impl</code>, due to the RFC punting it over complexity concerns.</p>
<p>Example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">type</span> <span class="nc">Output</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="k">fn</span> <span class="nf">create_secret_iterator</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="nb">Iterator</span><span class="o">&lt;</span><span class="n">Item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">Self</span>::<span class="n">Output</span><span class="o">&gt;</span><span class="p">;</span><span class="w"> </span><span class="c1">// -&gt; E0562</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<hr>
<p><a href="https://github.com/rust-lang/rust/issues/63063"><code>#![feature(type_alias_impl_trait)]</code></a> could theoretically solve this, if it allows the compiler to sidestep the <code>no impl in trait returns</code> limitation. I'll experiment.</p>



<a name="247107183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247107183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247107183">(Jul 25 2021 at 04:03)</a>:</h4>
<p>I'm running into <code>could not find defining uses</code> when attempting to use <code>type_alias_impl_trait</code> in a trait context; are you familiar enough with it to get it working?</p>
<p>I suspect the problem is that this mechanism names a <em>single</em> existential form, not all possible values of it, otherwise we would run into the same issues we currently hit with <code>impl</code> in traits.</p>



<a name="247122001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Generic%20Closure%20Wrapping%20without%20new%20type%3F/near/247122001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Generic.20Closure.20Wrapping.20without.20new.20type.3F.html#247122001">(Jul 25 2021 at 11:27)</a>:</h4>
<p>not sure, sorry</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>